#pragma strict

var qltyText : TextMesh;
var selectedQuality : int;
var curQ : String;
var buttonColorTo : Color32;
var buttonColorFrom : Color32;
var colorSpeed : float;

function Start(){

	buttonColorTo = Color32(246,255,0,0);
	buttonColorFrom = Color32(150,150,150,0);	
	colorSpeed = 20;
	selectedQuality = QualitySettings.GetQualityLevel();
	
	renderer.material.SetColor("_Color", buttonColorFrom);

}

function Update(){
	
	switch(selectedQuality){
		case(0):
		curQ = "Very Low";
		break;
		
		case(1):
		curQ = "Low";
		break;
		
		case(2):
		curQ = "Medium";
		break;
		
		case(3):
		curQ = "High";
		break;
		
		case(4):
		curQ = "Very High";
		break;
		
		case(5):
		curQ = "Ultra High";
		break;
	}
	
	qltyText.GetComponent(TextMesh).text = "Quality Preset: "+curQ;

}

function OnMouseEnter() {

	iTween.ColorTo(gameObject, buttonColorTo, colorSpeed * Time.deltaTime);

}

function OnMouseExit() {

	iTween.ColorTo(gameObject, buttonColorFrom, colorSpeed * Time.deltaTime);

}


function OnMouseDown(){
	
	if(selectedQuality == 5){
		selectedQuality = 0;
	} else { 
		selectedQuality += 1; 
	}
	
	QualitySettings.SetQualityLevel(selectedQuality);
	
}